package com.example.back.controller;

import com.example.back.entity.Chat;
import com.example.back.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
public class ChatController {
    @Autowired
    private ChatService chatService;
    @PostMapping("/chat")
    public int addChat(@RequestBody Chat chat){
        return chatService.addChat(chat);
    }
    @DeleteMapping("/chat/{id}")
    public int deleteChat(@PathVariable("id") Integer id){
        return chatService.deleteChat(id);
    }
    @GetMapping("/chat/{id}")
    public Chat queryChatById(@PathVariable("id") Integer id)
    {
        return chatService.queryChatById(id);
    }
    @GetMapping("/chat")
    public ArrayList<Chat> queryChat(Chat chat){
        return chatService.queryChat(chat);
    }

    @GetMapping("/chat/text/{fszId}/{jszId}")
    public ArrayList<Chat> queryChatText(@PathVariable("fszId") Integer fszId, @PathVariable("jszId") Integer jszId) {
        return chatService.queryChatText(fszId, jszId);
    }
}
